﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

/// <summary>
/// WWW 对象管理类
/// </summary>
[System.Serializable]
public class TMyFile
{

	public string url;
	public int count;		//引用计数
	public AssetBundleCreateRequest ac;
	public Object obj;
}

[System.Serializable]
public class WWWObject
{
	public string url;
//	public object parameter;
	public delegate void OnLoadOver(object parameter, TMyFile www);
//	public OnLoadOver onLoadOver;
	public TMyFile resource;
	
	public List<ParameterInfo> infoList = new List<ParameterInfo>();
	
	/// <summary>
	/// 创建正在下载资源
	/// </summary>
	/// <param name='parameter'>
	/// 下载对象所需的自定义参数
	/// </param>
	/// <param name='url'>
	/// WWW 对象的URL地址
	/// </param>
	/// <param name='method'>
	/// 下载完成后调用的代理函数
	/// </param>
	public WWWObject(object parameter, string url, OnLoadOver method)
	{
		this.url = url;
//		this.parameter = parameter;
//		onLoadOver += method;
		
		AddParameter(parameter, method);
	}
	
	public void AddParameter(object parameter, OnLoadOver method)
	{
		ParameterInfo info = new ParameterInfo();
		info.parameter = parameter;
		info.onLoadOver += method;
		infoList.Add(info);
	}
	
	public class ParameterInfo
	{
		public object parameter;
		public OnLoadOver onLoadOver;
	}
}
